MultiCurrencyServiceglobal with sharing class MultiCurrencyService this service provides the functionality to handle exchanges between multiple currencies in psa. Methods
useDatedExchangeRatesglobal static Boolean useDatedExchangeRates() Indicates if dated exchange rates are used for multi-currency conversions when PSA is configured to use currencies specified in the Currencies tab. Return ValueA Boolean indicating whether or not dated exchange rates are being used. Sample Code//Note: This sample code is for demonstration purposes only. It is not intended for //use in a production environment, is not guaranteed against defects or errors, and //is in no way optimized or streamlined. You need to provide some sample code useSalesforceAdvancedMultiCurrencyglobal static Boolean useSalesforceAdvancedMultiCurrency() When set to true, PSA uses the Salesforce advanced multi-currency feature. When set to false, PSA uses the currencies defined in the Currencies tab. Return ValueA Boolean indicating if PSA uses Salesforce Advanced Multi-Currency. Sample Code//Note: This sample code is for demonstration purposes only. It is not intended for //use in a production environment, is not guaranteed against defects or errors, and //is in no way optimized or streamlined. You need to provide some sample code getConvertedAmountglobal static Double getConvertedAmount(Double fromAmount, String fromCurrency, String toCurrency, Date d) Convert amount A of currency X to currency Y as of date D. Input Parameters
Return ValueA Double representing the resulting amount of the currency conversion. Sample Code//Note: This sample code is for demonstration purposes only. It is not intended for //use in a production environment, is not guaranteed against defects or errors, and //is in no way optimized or streamlined. You need to provide some sample code getConversionRatesByDateglobal static Map<Date, Map<String, Decimal>> getConversionRatesByDate(List<String> currencyCodeList, List<Date> dateList) Use a list of currency codes and a list of dates to get a map of dated currency codes to conversion rates. Input Parameters
Return ValueA Map of conversion Date to a Map of String currency codes to Decimal conversion rate. Sample Code//Note: This sample code is for demonstration purposes only. It is not intended for //use in a production environment, is not guaranteed against defects or errors, and //is in no way optimized or streamlined. You need to provide some sample code getConversionRatesByDateglobal static Map<Date, Map<String, Decimal>> getConversionRatesByDate(Set<String> currencyCodeSet, List<Date> dateList) Use a set of currency codes and a list of dates to get a map of dated currency codes to conversion rates. Input Parameters
Return ValueA Map of conversion Date to a Map of String currency code to Decimal conversion rates. Sample Code//Note: This sample code is for demonstration purposes only. It is not intended for //use in a production environment, is not guaranteed against defects or errors, and //is in no way optimized or streamlined. You need to provide some sample code getConversionRatesByDateglobal static Map<Date, Map<String, Decimal>> getConversionRatesByDate(List<String> currencyCodeList, Set<Date> dateSet) Use a list of currency codes and a set of dates to get a map of dated currency codes to conversion rates. Input Parameters
Return ValueA Map of conversion Date to a Map of String currency code to Decimal conversion rate. Sample Code//Note: This sample code is for demonstration purposes only. It is not intended for //use in a production environment, is not guaranteed against defects or errors, and //is in no way optimized or streamlined. You need to provide some sample code getConversionRatesByDateglobal static Map<Date, Map<String, Decimal>> getConversionRatesByDate(Set<String> currencyCodeSet, Set<Date> dateSet) Uses a set of currency codes and a set of dates to get a map of dated currency codes to conversion rates. Input Parameters
Return ValueA Map of conversion Date to a Map of String currency code to Decimal conversion rate. Sample Code//Note: This sample code is for demonstration purposes only. It is not intended for //use in a production environment, is not guaranteed against defects or errors, and //is in no way optimized or streamlined. You need to provide some sample code getConversionRateRatioByDateglobal static Decimal getConversionRateRatioByDate(String fromCurrencyCode, String toCurrencyCode, Date initialConversionDate, Date targetConversionDate) Get a decimal conversion rate ratio to convert one converted amount of currency A on conversion date X to currency B on conversion date Y. Input Parameters
Return ValueA Decimal conversion rate ratio that can be used to modify a Decimal converted currency amount on on initial Date to another Date. Sample Code//Note: This sample code is for demonstration purposes only. It is not intended for //use in a production environment, is not guaranteed against defects or errors, and //is in no way optimized or streamlined. You need to provide some sample code isCurrencyCorporateglobal static Map<String, Boolean> isCurrencyCorporate(Set<String> currencyCodeSet) Uses a set of currency codes to return a map of currency codes and associated Booleans indicating if the currency code is corporate. Input Parameters
Return ValueA Map of String currency codes to Boolean indicating whether the currency is the corporate one. Sample Code//Note: This sample code is for demonstration purposes only. It is not intended for //use in a production environment, is not guaranteed against defects or errors, and //is in no way optimized or streamlined. You need to provide some sample code MultiCurrencyService.ExchangeRateglobal with sharing class ExchangeRate exchangerate provides a multi-currency helper class Properties
Methods
ExchangeRateglobal ExchangeRate() Constructor. Creates an empty ExchangeRate. Return ValueAn empty ExchangeRate. Sample Code//Note: This sample code is for demonstration purposes only. It is not intended for //use in a production environment, is not guaranteed against defects or errors, and //is in no way optimized or streamlined. You need to provide some sample code ExchangeRateglobal ExchangeRate(Set<String> currencyCodeSet, Set<Date> dateSet) Constructor. Using a set of currency codes and a set of dates, creates an ExchangeRate for all combinations of these currencies and dates. Input Parameters
Return ValueAn ExchangeRate with permutations for all currencies and dates provided. Sample Code//Note: This sample code is for demonstration purposes only. It is not intended for //use in a production environment, is not guaranteed against defects or errors, and //is in no way optimized or streamlined. You need to provide some sample code ExchangeRateglobal ExchangeRate(Set<String> currencyCodeSet, Set<Date> dateSet, Integer scale) Constructor. Using a set of currency codes and a set of dates, creates an ExchangeRate for all combinations of these currencies and dates for the given precision scale. Input Parameters
Return ValueAn ExchangeRate with permutations for all currencies and dates provided of given scale precision. Sample Code//Note: This sample code is for demonstration purposes only. It is not intended for //use in a production environment, is not guaranteed against defects or errors, and //is in no way optimized or streamlined. You need to provide some sample code addDatedCurrencyglobal void addDatedCurrency(String currencyCode, Date conversionDate) Adds a dated currency for given currency on given date. Input Parameters
Sample Code//Note: This sample code is for demonstration purposes only. It is not intended for //use in a production environment, is not guaranteed against defects or errors, and //is in no way optimized or streamlined. You need to provide some sample code getDatedRateglobal Decimal getDatedRate(String currencyCode, Date rateDate) Get the exchange rate for a given currency on a given date. Input Parameters
Return ValueA Decimal representing the exchange rate for given currency on given date. Sample Code//Note: This sample code is for demonstration purposes only. It is not intended for //use in a production environment, is not guaranteed against defects or errors, and //is in no way optimized or streamlined. You need to provide some sample code convertAmountglobal Decimal convertAmount(Decimal fromAmount, String fromCurrencyCode, Date fromDate, String toCurrencyCode, Date toDate) Convert amount A1 from currency C1 on date D1 to currency C2 on date D2. Input Parameters
Return ValueA Decimal representing the converted amount in the given toCurrencyCode. Sample Code//Note: This sample code is for demonstration purposes only. It is not intended for //use in a production environment, is not guaranteed against defects or errors, and //is in no way optimized or streamlined. You need to provide some sample code |